//分类商品的小仓库
import { defineStore } from "pinia";
//分类接口
import { reqC1, reqC2, reqC3 } from '../../api/product/categorize'
//引入类型
import type { stateType } from "../type/categorize";
import type { responseData } from '../../api/product/categorize/type'
const categorizeStore = defineStore('categorize', {
  state: (): stateType => {
    return {
      info: [],
      infoId: '',
      info2: [],
      infoId2: '',
      info3: [],
      infoId3: ''
    }
  },
  actions: {
    //请求接口方法
    async getC1() {
      const result: responseData = await reqC1()
      if (result.code == 200) {
        this.info = result.data
        /*  console.log(this.info); */
      }
    },
    async getC2() {
      const result: responseData = await reqC2(this.infoId)
      if (result.code == 200) {
        this.info2 = result.data
      }
    },
    async getC3() {
      const result: responseData = await reqC3(this.infoId2)
      if (result.code == 200) {
        this.info3 = result.data
      }
    }
  }
})

export default categorizeStore